<?php

namespace common\util;

use common\entity\PagingEntity;

/**
 * @author ZWJ
 * @date 2024-07-22
 * @description think 分页工具
 */
class PagingUtil
{
    /**
     * 分页构建
     *
     * @param array $params
     * @return PagingEntity
     */
    public static function builder(array $params): PagingEntity
    {
        $pagingEntity = new PagingEntity();

        if (isset($params['page']) && !empty($params['page'])) {
            $pagingEntity->setPage($params['page']);
        }

        if (isset($params['limit']) && !empty($params['limit'])) {
            $pagingEntity->setLimit($params['limit']);
        }

        return $pagingEntity;
    }
}